﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Pg.BioMedics.SDR.Data.Configuration
{
    /// <summary>
    /// Data access settings element
    /// </summary>
    public class SettingsElement : ConfigurationElement
    {
        #region Constants

        private const string ConnectionStringNameProperty = "connectionStringName";
        private const string TransactionsEnabledProperty = "transactionsEnabled";

        #endregion

        #region Properties

        /// <summary>
        /// Gets / sets configuration connection string name
        /// </summary>
        [ConfigurationProperty(ConnectionStringNameProperty, IsRequired=true)]
        public string ConnectionStringName
        {
            get
            {
                return this[ConnectionStringNameProperty] as string;
            }

            set
            {
                this[ConnectionStringNameProperty] = value;
            }
        }

        /// <summary>
        /// Gets / sets flag if transactions are enabled
        /// </summary>
        [ConfigurationProperty(TransactionsEnabledProperty, IsRequired=true, DefaultValue=false)]
        public bool TransactionsEnabled
        {
            get
            {
                unchecked
                {
                    return (bool)this[TransactionsEnabledProperty];
                }
            }

            set
            {
                this[TransactionsEnabledProperty] = value;
            }
        }

        #endregion
    }
}
